#import subprocess
import json

input_file_name = input("Enter the name of the makefile: ")
input_file = open(input_file_name,'r')
input_file_json = json.loads( input_file.read())

dump_file= open( input_file_json['dump'],'w')
dump_file.write( input_file_name+' read\n')

def join(sources, dest):
    dest_file = open(dest,'w')
    for source in sources:
        dest_file.write( open(source,'r').read())

for action in input_file_json['actions']:
    if action['cmd'] == 'join':
        join( action['source'], action['target'])


##dump.write('compiling\n')
##sz  = ['java','-jar','compiler.jar','--js','./'+rules_name+'-cache.js','--compilation_level','WHITESPACE_ONLY','--js_output_file','../trunk/'+rules_name+'.js']
##dump.write('compiler options:\n')
##for s in sz:
##    dump.write(s+' ')
##dump.write('\n')
##
##proc = subprocess.Popen(sz).wait()


dump_file.write('done.\n')
dump_file.close()

